package com.bzgwl.mybatis_plus.config;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 获取controller日志
 *
 * @author liyongfei
 */
@Aspect
@Component
@Order(81)
@Slf4j
public class LogInfoAspect {

    @Pointcut("@annotation(com.bzgwl.mybatis_plus.config.LogInfo)" +
            "|| @within(com.bzgwl.mybatis_plus.config.LogInfo)")
    private void printLog() {
    }

    @Before("printLog()")
    public void before(JoinPoint joinPoint) {
        Signature signature = joinPoint.getSignature();
        String simpleName = signature.getDeclaringType().getSimpleName();
        String name = signature.getName();
        log.info("-----------------");
        log.info("请求{}:{}", simpleName, name);
        log.info("-----------------");
    }


}
